﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;

namespace QLHH_HD
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class HoaDonWindow : Window
    {
        public HoaDonWindow()
        {
            InitializeComponent();
        }

        public HoaDonWindow(DataRowView row)
        {
            // TODO: Complete member initialization
            this.row = row;
        }

        private void InitializeComponent()
        {
            throw new NotImplementedException();
        }
        HangHoa hanghoa = new HangHoa();
        private DataRowView row;
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt = hanghoa.DanhSachHangHoa();
            cboTenhang.ItemsSource = dt.DefaultView;
            cboTenhang.DisplayMemberPath = "tenhang";
            cboTenhang.SelectedValuePath = "mahang";

        }

        private void Button_Luu(object sender, RoutedEventArgs e)
        {
            HoaDon hd = new HoaDon();
            int sohoadon = int.Parse(txtsohoadon.Text);
            string mahang = cboTenhang.SelectedValue.ToString();
            int soluong = int.Parse(txtsoluong.Text);
            double dongia = int.Parse(txtdongia.Text);
            string diengiai = txtdiengiai.Text;
            hd.LuuHoaDon(sohoadon, mahang, diengiai, soluong, dongia);
            txtsohoadon.Focus();
            txtsohoadon.Text = null;
            cboTenhang.Text = null;
            txtsoluong.Text = null;
            txtdongia.Text = null;
            txtdiengiai.Text = null;

        }

        private void Button_Thoat(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}

